using System;
using System.Timers;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using API;
using Grpc.Core;
using mb;
using Mb;
using Xamarin.Forms;


namespace libhot
{
	public class TestSliderPage : ContentPage
	{
		public TestSliderPage()
		{
			var hrm = CatLib.App.Make<HotReloadManager>();
			hrm.RegisterReloadWeak(this, "testslider", (self, resName) =>
			{
				var me = self as TestSliderPage;
				me.Content = null;
				me.LoadXamlFromRes(resName);
				this.DoLoad();
			});
		}

		public TimeSpan Position
		{
			get; set;
		}
		public double MiSecond { get; set; }
		Timer tmTest;


		protected async void DoLoad()
		{
			tmTest = new Timer(100);
			tmTest.Elapsed += delegate
			{
				MiSecond += 10;
				if (MiSecond > 1000 * 15)
					MiSecond = 0;

				Position = TimeSpan.FromMilliseconds(MiSecond);
				// OnPropertyChanged();
				// OnPropertyChanged(nameof(Percent));
				OnPropertyChanged(nameof(Position));
			};
			tmTest.Start();
			Disappearing += delegate { tmTest.Stop(); };
		}

	}
}